package com.zxy.day0624_util.utils;

import java.security.MessageDigest;

/**
 * @Auther: lenovo
 * @Date: 2021/9/27 20:47
 * @Description:
 */
public class FileMd5Util {
    public FileMd5Util() {
    }

    public static String getMD5(String file) {
        StringBuffer sb = new StringBuffer("");

        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(file.getBytes());
            byte[] b = md.digest();

            for(int i = 0; i < b.length; ++i) {
                int d = b[i];
                if (d < 0) {
                    d = b[i] & 255;
                }

                if (d < 16) {
                    sb.append("0");
                }

                sb.append(Integer.toHexString(d));
            }
        } catch (Exception var6) {
            var6.printStackTrace();
        }

        return sb.toString();
    }
}
